import { Context } from 'koa'
export default function Authorization() {
  return async (ctx: Context, next: () => Promise<void>) => {
    return next().catch((err) => {
      if (401 == err.status) {
        ctx.status = 401
        ctx.body = {
          code: 401,
          msg: '权限不足! 请登录!',
        }
      } else {
        throw err
      }
    })
  }
}
